home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1122
/
1122.xpi
/
chrome
/
tabmixplus.jar
/
content
/
tabmixplus
/
pref
/
pref-appearance.xml
< prev
next >
Wrap
Extensible Markup Language
|
2009-09-19
|
12KB
|
288 lines
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % dialogDTD SYSTEM "chrome://tabmixplus/locale/pref-tabmix.dtd" >
%dialogDTD;
<!ENTITY % appearanceDTD SYSTEM "chrome://tabmixplus/locale/pref-appearance.dtd" >
%appearanceDTD;
]>
<bindings id="tmp_tabStylesbindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="tabstylepanel">
<content orient="vertical">
<xul:hbox align="center">
<xul:checkbox anonid="useThis" label="&useThis.label;: "
oncommand="_updateUseThisState(this.checked);"/>
<xul:label style="font-weight: bold;"/>
</xul:hbox>
<xul:separator class="groove"/>
<xul:hbox align="center" style="height: 28px;" xbl:inherits="hidden=_hidebox">
<xul:checkbox anonid="italic" xbl:inherits="disabled" label="&italic.label;" style="font-style: italic;"/>
<xul:checkbox anonid="bold" xbl:inherits="disabled" label="&bold.label;" style="font-weight: bold;"/>
<xul:checkbox anonid="underline" class="tabStyles_underline" xbl:inherits="disabled" label="&underline.label;"/>
</xul:hbox>
<xul:hbox align="center" xbl:inherits="hidden=_hidebox">
<xul:checkbox anonid="text" xbl:inherits="disabled" label="&textcolor.label;:"
oncommand="_setColorpicker(this.getAttribute('anonid'))"/>
<xul:spacer flex="1"/>
<xul:colorpicker anonid="textColor" palettename="standard" type="button" xbl:inherits="disabled=text-disabled"/>
<xul:label control="textOpacity" value="&opacity.label;[%]:" class="opacity" xbl:inherits="disabled=text-disabled"/>
<xul:textbox anonid="textOpacity" class="opacity" xbl:inherits="disabled=text-disabled"
maxlength="3" size="1" type="number" min="0" max="100" colorcontrol="text"
oncommand="_onOpacityChanged(this);"/>
</xul:hbox>
<xul:spacer flex="1" hidden="true" xbl:inherits="hidden=_hidespacer"/>
<xul:hbox align="center">
<xul:checkbox anonid="bg" xbl:inherits="disabled" label="&bgColor.label;:"
oncommand="_setColorpicker(this.getAttribute('anonid'))"/>
<xul:spacer flex="1" />
<xul:colorpicker anonid="bgColor" palettename="standard" type="button" xbl:inherits="disabled=bg-disabled"/>
<xul:label control="bgOpacity" value="&opacity.label;[%]:" class="opacity" xbl:inherits="disabled=bg-disabled"/>
<xul:textbox anonid="bgOpacity" class="opacity" xbl:inherits="disabled=bg-disabled"
maxlength="3" size="1" type="number" min="0" max="100" colorcontrol="bg"
oncommand="_onOpacityChanged(this);"/>
</xul:hbox>
<xul:separator class="groove"/>
<xul:hbox align="center">
<xul:button label="&settings.default;" oncommand="_resetDefault();"/>
</xul:hbox>
</content>
<implementation>
<constructor>
<![CDATA[
this.prefsSvc = TMPstyles.prefsSvc;
this._initUseThisPref = {prefvalue: this.prefsSvc.getBoolPref("extensions.tabmix." + this.id)};
this._initPrefValues = this.prefsSvc.getCharPref(this.prefName);
var checked;
var tabmixOptionsWindow = this._tabmixOptions;
if (tabmixOptionsWindow) {
this._initUseThisPref.optionvalue = checked = this._tabmixOptionsItem.checked;
this.prefsSvc.setBoolPref("extensions.tabmix." + this.id, checked);
tabmixOptionsWindow.updateApplyData(this._tabmixOptionsItem, checked);
}
else
checked = this._initUseThisPref.prefvalue;
if (this.id == "progressMeter")
this._getElementById("useThis").setAttribute("disabled" , true);
this._getElementById("useThis").checked = checked;
this.disabled = !checked;
this._getElementById("useThis").nextSibling.value = document.getElementById("_" + this.id).label;
// colorpicker need some time untile its ready
window.setTimeout( function(self) {self._getPrefs(self._initPrefValues);}, 0, this)
]]>
</constructor>
<field name="_initUseThisPref">null</field>
<field name="_initPrefValue">null</field>
<field name="prefsSvc">null</field>
<field name="_prefValues">null</field>
<property name="prefName"
onget="return 'extensions.tabmix.styles.' + this.id;"
readonly="true"/>
<field name="_tabmixOptionsItem">null</field>
<property name="_tabmixOptions" readonly="true">
<getter>
<![CDATA[
var win = window.opener;
this._tabmixOptionsItem = win.document.getElementById(this.id);
return win;
]]>
</getter>
</property>
<property name="disabled"
onget="return this.getAttribute('disabled');">
<setter>
<![CDATA[
if(val)
this.setAttribute("disabled", true);
else
this.removeAttribute("disabled");
]]>
</setter>
</property>
<method name="_getElementById">
<parameter name="aID"/>
<body><![CDATA[
return document.getAnonymousElementByAttribute(this, "anonid", aID);
]]></body>
</method>
<method name="_updateUseThisState">
<parameter name="aEnabled"/>
<body><![CDATA[
this.prefsSvc.setBoolPref("extensions.tabmix." + this.id, aEnabled);
var tabmixOptionsWindow = this._tabmixOptions;
if (tabmixOptionsWindow) {
this._tabmixOptionsItem.checked = aEnabled;
if (this.id == "progressMeter")
tabmixOptionsWindow.TM_Options.disabled("progressMeter");
}
this.disabled = !aEnabled
this._setColorpicker("bg");
if ("text" in this._prefValues)
this._setColorpicker("text");
]]></body>
</method>
<method name="_resetDefault">
<parameter name="aResetOnlyStyle"/>
<body><![CDATA[
if (!aResetOnlyStyle && this.prefsSvc.prefHasUserValue("extensions.tabmix." + this.id)) {
var useThis = this._getElementById("useThis");
useThis.checked = !useThis.checked;
this._updateUseThisState(useThis.checked);
this._initUseThisPref.prefvalue = this._initUseThisPref.optionvalue = useThis.checked;
}
var pref = this.prefName;
if (this.prefsSvc.prefHasUserValue(pref))
this.prefsSvc.clearUserPref(pref);
this._initPrefValues = this.prefsSvc.getCharPref(this.prefName);
this._getPrefs(this._initPrefValues);
]]></body>
</method>
<method name="_getPrefs">
<parameter name="aPrefString"/>
<body><![CDATA[
try {
this._prefValues = Components.utils.evalInSandbox("({" + aPrefString + "})",
new Components.utils.Sandbox("about:blank"));
}
catch (er) {
this._resetDefault(true);
return;
}
for (var _id in this._prefValues) {
var item = this._getElementById(_id);
if (!item)
continue;
switch (item.localName) {
case "checkbox":
item.checked = this._prefValues[_id];
break;
case "colorpicker":
// colorpicker use rgb hexadecimal format
var rgbArray = this._prefValues[_id].replace(/rgba|rgb|\(|\)/g, "").split(",");
var opacity = rgbArray.splice(3, 1);
item.color = "#" + rgbArray.map(function(aInt){return parseInt(aInt).toString(16).replace(/^(.)$/, "0$1")}
).join("").toUpperCase();
var controlID = _id.replace("Color", "Opacity");
this._getElementById(controlID).value = (opacity || 1 ) * 100;
break;
}
}
if ("text" in this._prefValues) {
this._setColorpicker("text");
this._prefValues["textOpacity"] = 1;
}
this._setColorpicker("bg");
this._prefValues["bgOpacity"] = 1;
]]></body>
</method>
<method name="_savePrefs">
<body><![CDATA[
var prefString = [];
for (var _id in this._prefValues) {
var item = this._getElementById(_id);
switch (item.localName) {
case "checkbox":
prefString.push(_id + ":" + item.checked);
break;
case "colorpicker":
prefString.push(_id + ":'" + item.color + "'");
break;
case "textbox":
prefString.push(_id + ":'" + item.value/100 + "'");
break;
}
}
this.prefsSvc.setCharPref(this.prefName, prefString.join(","));
]]></body>
</method>
<method name="_ondialogcancel">
<body><![CDATA[
this.prefsSvc.setCharPref(this.prefName, this._initPrefValues);
this.prefsSvc.setBoolPref("extensions.tabmix." + this.id, this._initUseThisPref.prefvalue);
var tabmixOptionsWindow = this._tabmixOptions;
if (tabmixOptionsWindow) {
tabmixOptionsWindow.updateApplyData(this._tabmixOptionsItem, this._initUseThisPref.optionvalue);
if (this.id == "progressMeter")
tabmixOptionsWindow.TM_Options.disabled("progressMeter");
}
]]></body>
</method>
<method name="_setColorpicker">
<parameter name="aID"/>
<body><![CDATA[
var opacity;
var enabled = this.disabled ? false : this._getElementById(aID).checked;
if (enabled) {
this.removeAttribute(aID + "-disabled");
opacity = this._getElementById(aID + "Opacity").value;
}
else {
this.setAttribute(aID + "-disabled", true);
opacity = 20;
}
this._setOpacity(aID, opacity);
]]></body>
</method>
<method name="_onOpacityChanged">
<parameter name="aOpacityControl"/>
<body><![CDATA[
var colorcontrolID = aOpacityControl.getAttribute("colorcontrol");
this._setOpacity(colorcontrolID, aOpacityControl.value);
]]></body>
</method>
<method name="_setOpacity">
<parameter name="aID"/>
<parameter name="aValue"/>
<body><![CDATA[
var opacity = aValue < 20 ? .20 : aValue/100;
var colorpicker = this._getElementById(aID + "Color");
colorpicker.setAttribute("style", "opacity: " + opacity);
]]></body>
</method>
</implementation>
<handlers>
<handler event="command">
this._savePrefs();
</handler>
<handler event="change">
if (event.originalTarget.localName == "colorpicker")
this._savePrefs();
</handler>
<handler event="input">
var item = event.originalTarget.parentNode.parentNode;
if (item.localName == "textbox") {
this._onOpacityChanged(item);
this._savePrefs();
}
</handler>
</handlers>
</binding>
</bindings>